package wowraidmanager.client.auction.admin;

import wowraidmanager.client.auction.admin.maintain.AdminAuctionItemList;
import wowraidmanager.client.auction.admin.maintain.AdminItemList;
import wowraidmanager.client.auction.admin.maintain.AdminRealmList;

import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.Widget;

public class Index extends Composite{

    private static IndexUiBinder uiBinder = GWT.create(IndexUiBinder.class);

    interface IndexUiBinder extends UiBinder<Widget, Index>{
    }

    @UiField
    MenuItem adminRealmList;

    @UiField
    MenuItem adminItemList;

    @UiField
    MenuItem adminAuctionList;

    @UiField
    FlowPanel mainPanel;

    public Index(){
        initWidget(uiBinder.createAndBindUi(this));
        setMenuEvent();
        setAdminRealmList();
    }


    private void setMenuEvent(){
        adminRealmList.setCommand(new Command(){

            public void execute(){
                setRemove();
                setAdminRealmList();
            }
        });

        adminItemList.setCommand(new Command(){

            public void execute(){
                setRemove();
                setAdminItemList();
            }
        });

        adminAuctionList.setCommand(new Command(){

            public void execute(){
                setRemove();
                setAdminAuctionList();

            }
        });
    }

    protected void setAdminAuctionList(){
        mainPanel.add(new AdminAuctionItemList());
    }


    protected void setAdminItemList(){
        mainPanel.add(new AdminItemList());

    }


    protected void setAdminRealmList(){
        mainPanel.add(new AdminRealmList());
    }


    protected void setRemove(){
        mainPanel.remove(0);
    }
}
